package com.company;

import java.util.Random;

// 生成5位的验证码,前4位为字母，最后一位为数字
public class Test3 {
    public static void main(String[] args) {
        char[] chs = new char[52];
        for (int i= 0; i < chs.length; i++) {
            // 利用ASCII码，将字母推送到数组中
            if(i <= 25) {
                chs[i] = (char) (97 + i);
            } else {
                chs[i] = (char) (65 + i - 26);
            }
        }

        String result = "";
        Random rand = new Random();

        for (int i = 0; i < 4; i++) {
            int randomIndex = rand.nextInt(chs.length);
            result += chs[randomIndex];

        }



        int number = rand.nextInt(10);
        result += number;

        System.out.println(result);
    }
}
